package com.chao.common.codeGeneration.source;

import com.chao.common.codeGeneration.bean.Table;
import com.chao.common.codeGeneration.generation.CodeConstant;

import java.io.File;

public class DeleteFile {

    public static void deleteAll(Table table, String path) {
        //删除业务路径
        String sePath = path + String.format(CodeConstant.SERVICE_PATH,table.getService(),table.getPacName());
        new File(sePath+"\\bean\\"+table.getPojoKey()+".java").delete();
        new File(sePath+"\\bean").delete();
        new File(sePath+"\\controller\\"+table.getPojoKey()+"Controller.java").delete();
        new File(sePath+"\\controller").delete();
//        new File(sePath+"\\feign\\"+table.getPojoKey()+"Mapper.java").delete();
        new File(sePath+"\\service\\"+table.getPojoKey()+"Service.java").delete();
        new File(sePath+"\\service\\impl\\"+table.getPojoKey()+"ServiceImpl.java").delete();
        new File(sePath+"\\service\\impl").delete();
        new File(sePath+"\\service").delete();
        new File(sePath+"\\mapper\\"+table.getPojoKey()+"Mapper.java").delete();
        new File(sePath+"\\mapper").delete();
        new File(sePath+"\\xml\\"+table.getPojoKey()+"Mapper.xml").delete();
        new File(sePath+"\\xml").delete();
        new File(sePath).delete();


//        //删除DB路径
//        String servicePag = Start.DB;
//        String dbPath = path + String.format(CodeConstant.SERVICE_PATH, Start.DB, servicePag, table.getPacName());
//        new File(dbPath+"\\feign\\"+table.getPojoKey()+"Feign.java").delete();
//        new File(dbPath+"\\mapper\\"+table.getPojoKey()+"Mapper.java").delete();
//        new File(dbPath+"\\xml\\"+table.getPojoKey()+"Mapper.xml").delete();
    }

}
